<template>
  <div></div>
</template>

<script setup>
import {useBaseParamStore} from '@/stores/baseParams'
import {useRoute, useRouter} from 'vue-router'
import {login} from '@/api/api'
import {showToast, showLoadingToast, closeToast} from 'vant'

// 配置基础信息存储
const baseParamStore = useBaseParamStore()
const baseParam = baseParamStore.getBaseParam

const route = useRoute()
const router = useRouter()
// 记录信息
baseParam.value.flockId = route.query.flockId
baseParam.value.businessType = route.query.businessType
baseParam.value.easPersonId = route.query.easPersonId
// baseParam.value.orgId = route.query.orgId
// baseParam.value.flockId = "ETiH+GzhSxyDNFHyMXp+o8B4fig="
// baseParam.value.businessType = "1"
// baseParam.value.easPersonId = "bDoAAAqbcAuA733t"

console.log(baseParam.value)

showLoadingToast({
  duration: 0,
  forbidClick: true,
  message: '登录中'
})

// 登录后 跳转对应业务页面
login()
    .then((res) => {
      closeToast()
      if (res.status && res.state == 'success') {
        console.log(res.data.access_token)
        baseParam.value.cqToken = res.data.access_token
        router.push({
          name: 'ServicePlatform'
        })
      } else {
        ElMessage.error('登录失败,请退出后尝试重新进入')
      }
    })
    .catch(() => {
      closeToast()
      ElMessage.error('登录失败,请退出后尝试重新进入')
    })
</script>
